import { defineConfig } from 'vite'
import autoImport from 'unplugin-auto-import/vite'
import components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import vue from '@vitejs/plugin-vue'
import { VarletUIResolver } from 'unplugin-vue-components/resolvers'

export default defineConfig({
  // ...
  plugins: [
    // ...
    vue(),
    autoImport({
      resolvers: [ElementPlusResolver(), VarletUIResolver({ autoImport: true })],
    }),
    components({
      resolvers: [ElementPlusResolver(), VarletUIResolver()],
    }),

  ],
  server: {
    proxy: {
      '/api': {
        target: 'http://localhost:3000', // 代理目标地址，即你的 Express 服务器地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''), // 将请求路径中的 '/api' 替换为空字符串
      },
      '/my-proxy': {
        target: 'http://api.qingyunke.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/my-proxy/, ''),
      }

    },
  },

  resolve: {
    alias: {
      '@': '/src'
    }
  }
})